<template>
    <div class="mui-numbox" data-numbox-min='1' style="height: 25px;width: 112px" >
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input id="test" class="mui-input-numbox" type="number" :value="initCount" @change="countChanged" ref="numbox" readonly/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script>
    import mui from '../../lib/mul/js/mui.min.js'
    export default {
        mounted() {
            mui(".mui-numbox").numbox();
        },
        methods:{
            countChanged(){
                // console.log(this.$refs.numbox.value);
                this.$store.commit("updateGoodsInfo",{
                    id:this.goodsId,
                    count:this.$refs.numbox.value
                })
            }
        },
        props:["initCount","goodsId"]
    }
</script>

<style scoped>
    .mui-numbox [class*=btn-numbox], .mui-numbox [class*=numbox-btn]{
        font-size: 18px;
        font-weight: 400;
        line-height: 100%;
        position: absolute;
        top: 0;
        overflow: hidden;
        width: 29px;
        height: 100%;
        padding: 0;
        color: #555;
        border: none;
        border-radius: 0;
        background-color: #f9f9f9;
    }
    .mui-numbox{
        position: relative;
        display: inline-block;
        overflow: hidden;
        width: 120px;
        height: 35px;
        padding: 0 30px;
        vertical-align: top;
        vertical-align: middle;
        border: solid 1px #bbb;
        border-radius: 3px;
        background-color: #efeff4;
    }
</style>